package com.zr.inquiry.partner.controller;

import com.zr.inquiry.partner.model.pojo.Partner;
import com.zr.inquiry.partner.model.pojo.SearchPartnerPageVo;
import com.zr.inquiry.partner.service.PartnerService;
import com.zr.utils.page.PageUtil;
import com.zr.utils.result.ResultBuilderUtil;
import com.zr.utils.result.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName PartnerController
 * @Description TODO 供应商控制器
 * @Author 马家奎
 * @Date 2019/11/14 18:16
 */
@CrossOrigin
@RestController
public class PartnerController {

    @Autowired
    private PartnerService partnerService;
    /*
    * @Author 马家奎
    * @Description //TODO 按法人的id查询供应商 * @Date
    * @Param legalPersonId
    * @return ResultUtil
    **/
    @GetMapping("partner/queryByLegalPerson")
    public ResultUtil queryPartnerByLegalPersonId(Integer legalPersonId){

        List<Partner> partnerList = partnerService.queryPartnerByLegalPersonId(legalPersonId);
        return ResultBuilderUtil.success(partnerList);
    }
    @PostMapping("material/searchPartnerPage")
    public ResultUtil queryPagePartner(@RequestBody SearchPartnerPageVo partnerPageVo){

        PageUtil<SearchPartnerPageVo> partnerList = partnerService.queryPagePartner(partnerPageVo);

        return ResultBuilderUtil.success(partnerList);
    }

}
